package com.imchen.cms.cmsweb.controller;

import com.imchen.cms.model.CommentsType;
import com.imchen.cms.service.CommentsTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;

/**
 * @author imchen
 * @create: 2019-01-30 14:52
 **/
@RestController()
@RequestMapping("/comments_type")
public class CommentsTypeController implements BaseController<CommentsType> {

    @Autowired
    private CommentsTypeService commentsTypeService;

    @Override
    @PostMapping("/add")
    public HashMap add(@RequestBody CommentsType commentsType) throws Exception {
        return commentsTypeService.add(commentsType);
    }

    @Override
    @GetMapping("/remove/{id}")
    public int remove(@PathVariable int id) {
        return commentsTypeService.removeById(id);
    }

    @Override
    @GetMapping("/delete/{id}")
    public int delete(@PathVariable int id) {
        return 0;
    }

    @Override
    @PostMapping("/update")
    public int update(CommentsType commentsType) {
        return commentsTypeService.update(commentsType);
    }

    @Override
    @GetMapping("/find/{id}")
    public HashMap<String, Object> find(@PathVariable int id) {
        return commentsTypeService.findByIdToMap(id);
    }
}